(31337_29662258275697, `The [highlight][patterns][/highlight] section is where we define text-replacement macros to reduce duplication in instruction definitions. Pattern structure is similar to instructions:

[color=#66ff99]Pattern signature[/color]
[color=#66ccff]Syntax replacement[/color]
[color=#9966ff]Machine code replacement[/color]

Example:
[box][patterns]

[color=#66ff99]pattern size(width, machine_code)[/color]
[color=#66ccff]U{width}[/color]
[color=#9966ff]00{machine_code}[/color]

[instructions]

mov_%s\[[color=#66ff99]size([/color][color=#66ccff]"8"[/color], [color=#9966ff]"00"[/color][color=#66ff99])[/color] | [color=#66ff99]size([/color][color=#66ccff]"16"[/color], [color=#9966ff]"01"[/color][color=#66ff99])[/color]] %a(reg) %b(reg)
0000 [color=#9966ff]%s[/color] %a %b
# Move to %a from %b

[/box]
After text replacement this becomes:
[box][instructions]

mov_[color=#66ccff]U8[/color] %a(reg) %b(reg)
0000 [color=#9966ff]0000[/color] %a %b
# Move to %a from %b

mov_[color=#66ccff]U16[/color] %a(reg) %b(reg)
0000 [color=#9966ff]0001[/color] %a %b
# Move to %a from %b

[/box]
In the example above, we first see a pattern being declared. The declaration starts with the "pattern" keyword and is followed by its name and after that names of arguments. The two lines below that are text snippets that will be pasted in to the syntax and machine code lines respectively.

In the instruction, the variables name [highlight]%s[/highlight] is placed in the syntax line. In the example, the parser enumerates each of the two version that [highlight]%s[/highlight] captures and instantiates a new instruction for each. It pastes in the syntax line and machine code snippets and replaces the pattern arguments with the given values.

`)